Skip to main content

from_unixtime

from_unixtime

Description

Syntax:

DATETIME FROM UNIXTIME (INT unix timestamp [, VARCHAR string format]

This function converts the UNIX timestamp to the corresponding time format. string_format specifies the format of the returned result.

It supports formats listed in data_format (Default: %Y-%m-%d %H:%i:%s).

The input is an integer while the output is a string.

Other string_format will be considered invalid and the function will return NULL.

Example

mysql> select from_unixtime(1196440219);
+---------------------------+
| from_unixtime(1196440219) |
+---------------------------+
| 2007-12-01 00:30:19 |
+---------------------------+

mysql> select from_unixtime(1196440219, '%Y-%m-%d');
+-----------------------------------------+
| from_unixtime(1196440219, '%Y-%m-%d') |
+-----------------------------------------+
| 2007-12-01 |
+-----------------------------------------+

mysql> select from_unixtime(1196440219, '%Y-%m-%d %H:%i:%s');
+--------------------------------------------------+
|From unixtime (1196440219,'%Y-%m-%d %H:%i:%s') |
+--------------------------------------------------+
| 2007-12-01 00:30:19 |
+--------------------------------------------------+

Keywords

FROM_UNIXTIME,FROM,UNIXTIME